<?php

namespace App\Jobs;

use App\Models\Order;
use App\Models\OrderConfig;
use App\Models\Package;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

/**
 * 清关成功后的操作
 */
class OrderInvt800 implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    /**
     * @var int
     * @author luffyzhao@vip.126.com
     */
    private $orderkey;

    /**
     * Create a new job instance.
     *
     * @param int $orderkey
     */
    public function __construct($orderkey)
    {
        $this->orderkey = $orderkey;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        // 获取包材
        OrderConfig::query()->create([
            'order_id' => $this->orderkey,
            'key' => 'packing',
            'value' => Package::query()->first()->value('id'),
        ]);
    }
}
